c     numerical integration to calculate pi

      program pi
      integer i, n
      real*8 w, v(:), gsum, pi

      print *, 'Input number of points : '
      read *, n
      call cm_timer_clear (0)
      call cm_timer_start (0)
      w = 1.0 / n
      allocate (v(n))
      v = ([1:n] -0.5 )* w
      v = 4.0 / (1.0 + v * v)
      gsum = sum (v)
      call cm_timer_stop (0)
      print *, 'pi ist approximated with ', gsum *w
      call cm_timer_print (0)
      deallocate (v)
      end
